<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>

<link rel="stylesheet" type="text/css" href="../bootstarp-3.3.7/css/bootstrap.min.css"/>
<script src="../assets/js/jquery-2.0.3.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../bootstarp-3.3.7/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>

<link rel="stylesheet" type="text/css" href="../bootstarp-table-1.11.1/bootstrap-table.min.css"/>
<script src="../bootstarp-table-1.11.1/bootstrap-table.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../bootstarp-table-1.11.1/bootstrap-table-zh-CN.min.js" type="text/javascript" charset="utf-8"></script>

   <script type="text/javascript">
   	
   	$(function() {
				$("#table").bootstrapTable({
					url: "../hw/hwdas.lgg",
					type:"POST",
					pagination: true,
					pageSize: 3,
					queryParams: queryParams,
					
					columns: [{
						field: "pid",
						title: "货物ID",
						align: "center",
					},{
						field: "pname",
						title: "货物名称",
						align: "center",
					},{
						field: "catery",
						title: "货物类别",
						align: "center",
					},{
						field: "pmodel",
						title: "产品型号",
						align: "center",
					},{
						field: "code",
						title: "产品编码",
						align: "center",
					},{
						field: "provider",
						title: "供应商",
						align: "center",
					},{
						field: "package_id",
						title: "定制单位ID",
						align: "center",
					},{
						field: "status",
						title: "货物状态",
						align: "center",
					},{
						title: "修改",
						align: "center",
						formatter: function(value,row,index) {
                           return '<button onclick="hwxui('+row.pid+')" class="btn btn-info glyphicon glyphicon-edit" data-toggle="modal" data-target=""></button>'
						}
					},{
						title: "删除",
						align: "center",
						formatter: function(value,row,index) {
							return '<button onclick="shanchu('+row.pid+')" class="btn btn-danger glyphicon glyphicon-trash" data-toggle="modal" data-target=""></button>'
						}
					}]
				})
				})


               //添加
	            function hwadd() {	 
	            	$.ajax({
	            		type:"post",
	            		url:"../hw/hwinsert.lgg",
	            		 data:$("#myformss").serialize(),
	            		success:function (data) {
	            			alert(data)
	            	//隐藏
	            			$("#myModal").modal("hide")
	            	//刷新
	            			$("#table").bootstrapTable('refresh')
	            		}
	            	});	 
	               }
	
             
               /* 删除 */
		         function shanchu(pid) {
			            $.ajax({
			             url : "../hw/hwdel.lgg",
				         data : "pid="+pid,
				         type : "post",
				 //刷新
			        	success : function(data) {			        		
				     	$("table").bootstrapTable("refresh");
				       }
			           })
			          }
	            
   //模糊查询         
	function queryParams(){
		return {
			'pname':$("#pname").val(),
			'code':$("#code").val()
		}
	}
//模糊查询后刷新表格
function mh(){
	$("table").bootstrapTable("refresh");
}


//单位修改展示模态框
                function hwxui(pid){             
                	$("#myModal123").modal('show');
                	//拿值
                	$.ajax({
                		type:"post",
                		url:"../hw/hwxui.lgg",
                		data:"pid=" + pid,
                		success:function (data) {
                			 $("#pid").val(data.pid);
                			$("#pname2").val(data.pname);
                			$("#cater2").val(data.catery);
                			$("#pmode2").val(data.pmodel);
                			$("#cod2").val(data.code);
                			$("#provide2").val(data.provider);
                			$("#package_i2").val(data.package_id);
                			$("#statu2").val(data.status);
                		}
                	});
                }	
 //修改
             function hwupdate() {
//           	alert($("#myformss111").serialize())
                $.ajax({
					type: "post",
					url: "../hw/hwupdate.lgg",
					data:$("#myformss111").serialize(),
					success: function(data) {		
						$("#myModal123").modal("hide")
						$("#table1").bootstrapTable('refresh')
					}
				});
				
              }

   </script>

<body>


<div align="center">
<form id="mo" class="form-inline">
<input type="text" name="pname" class="form-control" style="width: 150px;" placeholder="请输入货物名称" id="pname"/>
<input type="text" name="code" class="form-control" style="width: 150px;" placeholder="请输入产品编码" id="code"/>
<button type="button" id="cha" class="btn btn-default glyphicon glyphicon-search" onclick="mh()"></button>
<button type="button" class="btn btn-primary glyphicon glyphicon-plus" data-toggle="modal" data-target="#myModal"></button>
	
</form>
</div>
<br />

	<!-- Modal -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document"> 
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
						</button>
						<h4 class="modal-title" id="myModalLabel">货物基本信息</h4>
						
				</div>
				<div class="modal-body">

                     <!--表单 -->
<form class="form-horizontal" id="myformss">
					
<div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">货物名称</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="pname" name="pname" placeholder="请输入货物名称">
    </div>
  </div>
  
  
  
<div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">货物类别</label>
    <div class="col-sm-10">
     <input type="email" class="form-control" id="cater" name="catery" placeholder="请输入单位类型"><lect>
    </div>
  </div>
  
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">产品型号</label>
    <div class="col-sm-10">
     <input type="email" class="form-control" id="pmode" name="pmodel" placeholder="请输入产品型号"><lect>
    </div>
  </div>
  
  
  
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">产品编号</label>
    <div class="col-sm-10">
     <input type="email" class="form-control" id="cod" name="code" placeholder="请输入产品编号"><lect>
    </div>
  </div>
  
  
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">供应商</label>
    <div class="col-sm-10">
     <input type="email" class="form-control" id="provide" name="provider" placeholder="请输入供应商"><lect>
    </div>
  </div>
  
  
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">创建日期</label>
    <div class="col-sm-10">
     <input type="date" class="form-control" id="create_dat" name="create_date" placeholder="请输入创建日期"><lect>
    </div>
  </div>
  

  
  
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">货物状态</label>
    <div class="col-sm-10">
     <input type="email" class="form-control" id="statu" name="status" placeholder="请输入货物状态"><lect>
    </div>
  </div>
     <div class="modal-footer">
        <button type="button" class="btn btn-danger glyphicon glyphicon-remove" data-dismiss="modal"></button>
      <button type="button" class="btn btn-success glyphicon glyphicon-ok" id="btn" onclick="hwadd()"></button>   
      </div>
  </form>
  
 
    </div>
     </div>
 </div>
    </div>


<table class="table table-responsive" id="table"></table>






<!-- 修改 -->
	<div class="modal fade" id="myModal123" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document"> 
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
						</button>
						<h4 class="modal-title" id="myModalLabel">货物基本信息</h4>
						
				</div>
				<div class="modal-body">

                     <!--表单 -->
<form class="form-horizontal" id="myformss111">
			
			
<div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">货物id</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="pid" name="pid" readonly="readonly">
    </div>
  </div>			
			
<div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">货物名称</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="pname2" name="pname" placeholder="请输入货物名称">
    </div>
  </div>
  
  
  
<div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">货物类别</label>
    <div class="col-sm-10">
     <input type="email" class="form-control" id="cater2" name="catery" placeholder="请输入单位类型"><lect>
    </div>
  </div>
  
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">产品型号</label>
    <div class="col-sm-10">
     <input type="email" class="form-control" id="pmode2" name="pmodel" placeholder="请输入产品型号"><lect>
    </div>
  </div>
  
  
  
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">产品编号</label>
    <div class="col-sm-10">
     <input type="email" class="form-control" id="cod2" name="code" placeholder="请输入产品编号"><lect>
    </div>
  </div>
  
  
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">供应商</label>
    <div class="col-sm-10">
     <input type="email" class="form-control" id="provide2" name="provider" placeholder="请输入供应商"><lect>
    </div>
  </div>
  
 
 
  
  
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">货物状态</label>
    <div class="col-sm-10">
     <input type="email" class="form-control" id="statu2" name="status" placeholder="请输入货物状态"><lect>
    </div>
  </div>
     <div class="modal-footer">
        <button type="button" class="btn btn-danger glyphicon glyphicon-remove" data-dismiss="modal"></button>
      <button type="button" class="btn btn-success glyphicon glyphicon-ok" onclick="hwupdate()"></button>   
      </div>
  </form>
  
 
    </div>
     </div>
 </div>
    </div>


<table class="table table-responsive" id="table1"></table>





</body>
</html>